<?php echo $this->fetch('header.html'); ?>  
<style>
.s-items .iconfont{font-size:12px;}
.s-items .iconfont.active{color:orangered}
</style>  
<div class="mb-head">
    <a href="javascript:history.back(-1)" class="l_b"></a>
    <!--<div class="tit">产品搜索</div>-->
    <div class="search">
        <div class="search-box">
            <form>
                <input type="hidden" name="app" value="search"/>
                <input type="hidden" name="act" value="index"/>
                <input type="text" name="keyword"  value="" placeholder="搜索你关注的商品" class="keyword" />
                <input type="submit" class="search-btn" value="" />
            </form>
        </div>
    </div>
    <a href="<?php echo url('app=category'); ?>" class="r_b icon-cat">分类</a>
</div>

<script type="text/javascript" src="<?php echo $this->res_base . "/" . 'js/search_goods.js'; ?>" charset="utf-8"></script>
<script>
    $(function () {
	var order = '<?php echo ($_GET['order'] == '') ? 'default asc' : $_GET['order']; ?>';
	order_arr = order.split(' ');
	$( '#'+order_arr[0]+' .iconfont').addClass('active');
	switch (order_arr[1]){
		case 'desc' :
			$( '#'+order_arr[0]+' .iconfont').html("&#Xf0122");
		break;
		case 'asc' :
			$('#'+order_arr[0]+' .iconfont').html("&#Xf0121");
		break;
		
	}
        $("*[ectype='wap_order_by'] a").click(function () {
            replaceParam('order', this.id + " "+((order_arr[1]=='asc')?'desc':'asc'));
            return false;
        });
        
        x = $("#cat_<?php echo $this->_var['cate_id']; ?>").offset();
        if($("#cat_<?php echo $this->_var['cate_id']; ?>").length>0 && x.left > $(document).width()){
            $(".tab-ul").scrollLeft(x.left-$(document).width()/2.0);
        }
        
    })  
</script>
<section class="new-tab" style="display: ;">
    <ul class="tab-ul">
        <li <?php if ($this->_var['cate_id'] == 0): ?> class="cur"<?php endif; ?>><a href="<?php echo url('app=search'); ?>">全部</a></li>
        <?php $_from = $this->_var['header_gcategories']['gcategories']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'category');$this->_foreach['fe_category'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_category']['total'] > 0):
    foreach ($_from AS $this->_var['category']):
        $this->_foreach['fe_category']['iteration']++;
?>
        <li id="cat_<?php echo $this->_var['category']['id']; ?>" <?php if ($this->_var['cate_id'] == $this->_var['category']['id']): ?> class="cur"<?php endif; ?>><a href="<?php echo url('app=search&cate_id=' . $this->_var['category']['id']. ''); ?>"><?php echo htmlspecialchars($this->_var['category']['value']); ?></a></li>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </ul>
</section>
<section class="search_goods_options" id="sort_order">
    <ul class="s-items" ectype='wap_order_by'>
        <li><a href="javascript:void(0);" <?php if ($_GET['order'] == ' sales desc '): ?>class="selected" <?php endif; ?>id="sales" >销量<i class="iconfont">&#Xf0122</i><span class="decollator">|</span></a></li>
        <li><a href="javascript:void(0);" id="price">价格<i class="iconfont">&#Xf0122</i><span class="decollator">|</span></a></li>
        <li><a href="javascript:void(0);" id="add_time">新品<i class="iconfont">&#Xf0122</i><span class="decollator">|</span></a></li>
        <li><a href="javascript:void(0);" id="comments">好评<i class="iconfont">&#Xf0122</i><span class="decollator">|</span></a></li>
    </ul>
</section>


<section class="search_goods">
    <?php if (! $this->_var['goods_list_order']): ?>
    <ul class="list">

        <?php $_from = $this->_var['goods_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'goods');$this->_foreach['fe_goods'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_goods']['total'] > 0):
    foreach ($_from AS $this->_var['goods']):
        $this->_foreach['fe_goods']['iteration']++;
?>
        <a href="<?php echo url('app=goods&id=' . $this->_var['goods']['goods_id']. ''); ?>">
            <li>
                <img src="<?php echo $this->_var['site_url']; ?>/<?php echo $this->_var['goods']['default_image']; ?>" alt="<?php echo $this->_var['goods']['name']; ?>"/>
                <div class="detail">
                    <p class="title"><?php echo htmlspecialchars($this->_var['goods']['goods_name']); ?></p>
                    <p class="price"><?php echo price_format($this->_var['goods']['price']); ?></p>
                </div>
            </li>
        </a>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </ul>
    <?php else: ?>
    <div class="null">
        <p>很抱歉！没有找到相关商品~</p>
    </div>
    <?php endif; ?>
    <?php echo $this->fetch('page.bottom.html'); ?>
</section>



<?php echo $this->fetch('footer.html'); ?>